PyIgnition

https://github.com/animatinator/PyIgnition update for Python 3
Clone: git clone https://git.frombelow.net/PyIgnition.git
Log | Files | Refs | README

Catherine wheel.py (1411B)


      1 # Catherine wheel
      2 
      3 import PyIgnition, pygame, sys
      4 
      5 
      6 screen = pygame.display.set_mode((600, 600))
      7 pygame.display.set_caption("PyIgnition demo: catherine wheel")
      8 clock = pygame.time.Clock()
      9 
     10 wheel = PyIgnition.ParticleEffect(screen, (0, 0), (600, 600))
     11 flame = wheel.CreateSource((300, 300), initspeed = 20.0, initdirection = 0.0, initspeedrandrange = 0.0, initdirectionrandrange = 0.5, particlesperframe = 3, particlelife = 50, drawtype = PyIgnition.DRAWTYPE_SCALELINE, colour = (255, 200, 200), length = 20.0)
     12 sparks = wheel.CreateSource((300, 300), initspeed = 1.0, initdirection = 0.0, initspeedrandrange = 0.9, initdirectionrandrange = 3.141592653, particlesperframe = 1, particlelife = 300, genspacing = 3, drawtype = PyIgnition.DRAWTYPE_IMAGE, imagepath = "Spark.png")
     13 wheel.CreateDirectedGravity(strength = 0.05, direction = [0, 1])
     14 
     15 velocity = 0.1
     16 maxvelocity = 0.5
     17 acceleration = 0.001
     18 
     19 
     20 while True:
     21 	for event in pygame.event.get():
     22 		if event.type == pygame.QUIT:
     23 			sys.exit()
     24 			
     25 		elif event.type == pygame.KEYDOWN:
     26 			if event.key == pygame.K_s:
     27 				wheel.SaveToFile("Test.xml")
     28 	
     29 	flame.SetInitDirection(flame.initdirection + velocity)
     30 	if flame.curframe % 30 == 0:
     31 		flame.ConsolidateKeyframes()
     32 	
     33 	if velocity <= maxvelocity:
     34 		velocity += acceleration
     35 	
     36 	screen.fill((10, 0, 50))
     37 	wheel.Update()
     38 	wheel.Redraw()
     39 	pygame.display.update()
     40 	clock.tick(30)